<?xml version='1.0' encoding='UTF-8' ?>
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
        xmlns:my='http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-12-14T10:15:01'>
        <xsl:output method='xml' standalone='yes' />
        <xsl:template match='my:myFields'>
        <DynamicEntity Name='csp_taxdeclaration' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' 
        xmlns:xsd='http://www.w3.org/2001/XMLSchema' >
        <Properties xmlns='http://schemas.microsoft.com/crm/2006/WebServices'>

					<xsl:if test='//my:CitizenAddress/text()'>
						<Property xsi:type='StringProperty' Name='csp_address'>
							<Value><xsl:value-of select='//my:CitizenAddress'/></Value>
						</Property>
					</xsl:if>

					<xsl:if test='//my:CitizenCity/text()'>
						<Property xsi:type='StringProperty' Name='csp_city'>
							<Value><xsl:value-of select='//my:CitizenCity'/></Value>
						</Property>
					</xsl:if>

					<xsl:if test='//my:CitizenZip/text()'>
						<Property xsi:type='StringProperty' Name='csp_postalcode'>
							<Value><xsl:value-of select='//my:CitizenZip'/></Value>
						</Property>
					</xsl:if>

					<xsl:if test='//my:CitizenEmail/text()'>
						<Property xsi:type='StringProperty' Name='csp_emailaddress'>
							<Value><xsl:value-of select='//my:CitizenEmail'/></Value>
						</Property>
					</xsl:if>

					<xsl:if test='//my:CitizenPhone/text()'>
						<Property xsi:type='StringProperty' Name='csp_phone'>
							<Value><xsl:value-of select='//my:CitizenPhone'/></Value>
						</Property>
					</xsl:if>

					<xsl:if test='//my:CitizenFax/text()'>
						<Property xsi:type='StringProperty' Name='csp_fax'>
							<Value><xsl:value-of select='//my:CitizenFax'/></Value>
						</Property>
					</xsl:if>
        <xsl:if test='//my:TaxDeclarationAnnualCharge/text()'>
        <Property xsi:type='CrmMoneyProperty' Name='csp_annualcharge'>
          <Value><xsl:value-of select='//my:TaxDeclarationAnnualCharge'/></Value>
        </Property>
        </xsl:if>

        <xsl:if test='//my:TaxDeclarationMonthlyCharge/text()'>
        <Property xsi:type='CrmMoneyProperty' Name='csp_monthlycharge'>
          <Value><xsl:value-of select='//my:TaxDeclarationMonthlyCharge'/></Value>
        </Property>
        </xsl:if>

        <xsl:if test='//my:TaxDeclarationPaymentAmount/text()'>
        <Property xsi:type='CrmMoneyProperty' Name='csp_paymentamount'>
          <Value><xsl:value-of select='//my:TaxDeclarationPaymentAmount'/></Value>
        </Property>
        </xsl:if>

        <xsl:if test='//my:TaxDeclarationPaymentDate/text()'>
        <Property xsi:type='CrmDateTimeProperty' Name='csp_paymentdate'>
          <Value><xsl:value-of select='//my:TaxDeclarationPaymentDate'/></Value>
        </Property>
        </xsl:if>
					
				<xsl:if test='//my:TaxDeclarationPaymentMethod/text()'>
				<Property xsi:type='PicklistProperty' Name='csp_paymentmethod'>
				<xsl:choose>
				<xsl:when test="//my:TaxDeclarationPaymentMethod='Cheque'"><Value>1</Value></xsl:when>
				<xsl:when test="//my:TaxDeclarationPaymentMethod='Bank Transfer'"><Value>2</Value></xsl:when>
				<xsl:when test="//my:TaxDeclarationPaymentMethod='Visa'"><Value>3</Value></xsl:when>
				</xsl:choose>
				</Property>
				</xsl:if>


        <xsl:if test='//my:TaxDeclarationTaxNumber/text()'>
        <Property xsi:type='StringProperty' Name='csp_taxnumber'>
          <Value><xsl:value-of select='//my:TaxDeclarationTaxNumber'/></Value>
        </Property>
        </xsl:if>

				<xsl:if test='//my:TaxDeclarationTypeOfTax/text()'>
				<Property xsi:type='PicklistProperty' Name='csp_type'>
				<xsl:choose>
				<xsl:when test="//my:TaxDeclarationTypeOfTax='Local Tax'"><Value>1</Value></xsl:when>
				<xsl:when test="//my:TaxDeclarationTypeOfTax='Water'"><Value>2</Value></xsl:when>
				<xsl:when test="//my:TaxDeclarationTypeOfTax='Sewage'"><Value>3</Value></xsl:when>
				<xsl:otherwise><Value>100</Value></xsl:otherwise>
				</xsl:choose>
				</Property>
				</xsl:if>

				</Properties>
				</DynamicEntity>
				
				</xsl:template>

</xsl:stylesheet>
